<template>
	<view>
		<view class="logo">
			<view class="title">
				Hello!
			</view>
			<view class="idcr">
				{{ config.name }}。
			</view>
		</view>
		<view class="block" style="width: 100%;height: 150rpx;">

		</view>
		<view class="from">
			<view class="form_input">
				<view class="from_title" style="font-weight: bold;margin-left: 20rpx;margin-bottom: 15rpx;">
					<text style="color: #ff5502;padding-right: 4rpx;">*</text>
					<text style="font-size: 34rpx;">昵称</text>
				</view>
				<u-input border="bottom" maxlength="11" v-model="nickname" placeholder="请输入昵称">

				</u-input>
			</view>
			<view class="form_input">
				<view class="from_title" style="font-weight: bold;margin-left: 20rpx;margin-bottom: 15rpx;">
					<text style="color: #ff5502;padding-right: 4rpx;">*</text>
					<text style="font-size: 34rpx;">手机号</text>
				</view>
				<u-input border="bottom" maxlength="11" v-model="mobile" placeholder="请输入手机号码">

				</u-input>
			</view>
			<view class="form_input" style="margin-top: 80rpx;">
				<view class="from_title" style="font-weight: bold;margin-left: 20rpx;margin-bottom: 15rpx;">
					<text style="color: #ff5502;padding-right: 4rpx;">*</text>
					<text style="font-size: 34rpx;">密码</text>
				</view>
				<u--input type="password" v-model="password" placeholder="请输入设置的密码" border="bottom" clearable>
				</u--input>
			</view>
			<view class="register" @tap="login">
				已有账号？
			</view>
		</view>
		<view class="submit">
			<button @tap="submit">立 即 注 册</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mobile: '',
				password: '',
				nickname: '',
				config: ''
			}
		},
		onLoad() {
			this.Getconfig()
		},
		methods: {
			Getconfig() {
				uni.showLoading({
					title: '正在加载'
				})
				this.$http.Post('zter/shopInfo', {}, (result) => {
					this.config = result.data
					uni.hideLoading()
				})
			},
			login() {
				uni.navigateTo({
					url: '/pages/login/index'
				})
			},
			submit() {
				if (!this.mobile) {
					uni.showToast({
						title: '请输入手机号'
					})
					return
				}
				if (!this.password) {
					uni.showToast({
						title: '请输入密码'
					})
					return
				}
				if (!this.nickname) {
					uni.showToast({
						title: '请输入昵称'
					})
					return
				}
				this.$http.Post('user/register', {
					mobile: this.mobile,
					password: this.password,
					nickname: this.nickname,
				}, (result) => {

					uni.showToast({
						title: '注册成功',
						icon: 'success'
					})
					setTimeout(res => {
						uni.navigateTo({
							url: '/pages/login/index'
						})
					}, 500)

				})
			},
		}
	}
</script>

<style>
	page {
		background-image: url(https://oss.jinchaoshuju.com/images/c89317f2f3684e2db5dfa86c63c6653c.png);
		background-size: 100% 100%;
		height: 90vh;
	}
</style>
<style>
	.register {
		width: 100%;
		display: flex;
		color: #8aa8dd;
		display: flex;
		justify-content: flex-end;
	}

	.logo {
		margin-top: 150rpx;
		width: 100%;
	}

	.icon {
		width: 100%;
		height: 200rpx;
		display: flex;
		justify-content: center;
		align-items: flex-end;
	}

	.title {
		width: 600rpx;
		margin: 0 auto;
		font-size: 42rpx;
		font-weight: bold;
	}

	.idcr {
		width: 600rpx;
		margin: 20rpx auto 0 auto;
		font-size: 42rpx;
		font-weight: bold;
	}

	.from {
		width: 600rpx;
		border: 1rox solid black;
		margin: 80rpx auto 0 auto;
	}

	.form_input {
		margin: 45rpx auto;
	}


	.agreement {
		width: 94%;
		margin: 140rpx auto 20rpx auto;
		font-size: 26rpx;
		display: flex;
		align-items: center;
	}

	.submit {
		width: 600rpx;
		height: 90rpx;
		margin: 160rpx auto 0 auto;
	}

	.submit>button {
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #fff;
		background-color: #ff5502;
		font-size: 28rpx;
		border-radius: 999rpx;
	}


	.loginAd {
		margin: 60rpx auto 20rpx auto;
		width: 600rpx;
		height: 200rpx;
	}


	.loginAd>image {
		width: 100%;
		height: 100%;
		border-radius: 20rpx;
	}
</style>
